<?php
include ("../admin/conectar.php"); //Conecta com a nosso banco de dados MySQL
include ("../admin/ver_sessao.php");  //Verifica se a sessão está ativa

if (isset($_SESSION['dados'])) {
	$dados = $_SESSION['dados'];
}
if (($dados['login_user'])==(admin)){
$usrSQL = mysql_query("SELECT * FROM tb_admin");
}

else {
$login_user=$dados['login'];
$usrSQL = mysql_query("SELECT * FROM tb_login WHERE login='$login_user'");
//$usrSQL = mysql_query("SELECT id_user,date_format(inclusao_user,'%d/%m/%Y - %H:%i') as inclusao_user, nome_user,cidade_user,estado_user FROM tb_admin WHERE nome_user='$nome_user'");
}

$usuarioSQL = mysql_query("SELECT * FROM tb_login");
/*Data*/
$data = date('d/m/y');
	$hora = date('H');
	$minute = date('i');
	$hour=($hora - 1);
	$day = date('d');
	$month= date('m');
	$year= (2000 + date('y'));
	
	/**********************************************************/
	switch ($month) {
    case 1:
        $mes = Jan;
        break;
    case 2:
        $mes = Fev;
        break;
	case 3:
        $mes = Mar;
        break;
	case 4:
        $mes = Abr;
        break;
	case 5:
        $mes = Mai;
        break;
	case 6:
        $mes = Jun;
        break;
	case 7:
        $mes = Jul;
        break;
	case 8:
        $mes = Ago;
        break;
    case 9:
        $mes = Set;
        break;
	case 10:
        $mes = Out;
        break;
	case 11:
        $mes = Nov;
        break;
	case 12:
        $mes = Dez;
        break;
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/admin.conta.dwt" codeOutsideHTMLIsLocked="false" -->
<head>

<title>.:: Expert3d - <?php echo ($dados['login_user']); ?>::.</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="images/favicon.ico" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
function clearText(field) {
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}
</script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body>
<div id="header">
  <div id="site_title"> <a href="#">Soluções Tecnológicas</a> </div>
  <div id="header_right"> <a href="#"><img src="images/twitter.png" alt="" /></a><a href="#"><img src="images/rss.png" alt="" /></a>
    <div id="newsletter_box">
      <form action="#" method="get">
        <input type="text" id="user" name="user" class="newsletter_email" value="Enter your email address"  onfocus="clearText(this)" onblur="clearText(this)" />
        <input style="font-weight: bold;" type="submit" name="submit" id="submit" value="" />
      </form>
    </div>
  </div>
  <div class="cleaner"></div>
</div>
<!-- end of header -->
<div id="menu_wrapper">
  <div id="menu">
    <ul>
      <li><a href="home.php" class="current"><span></span>Home</a></li>
      <li><a href="#"><span></span>Web 2.0</a></li>
      <li><a href="#"><span></span>CSS Templates</a></li>
      <li><a href="#"><span></span>Graphics</a></li>
      <li><a href="#"><span></span>Inspirations</a></li>
      <li><a href="conta.php"><span></span>Minha Conta </a></li>
	  <li><a href="sair.php"><span></span>Sair </a></li>
    </ul>
  </div>
</div>
<!-- end of menu -->
<div id="main"> <span class="tm_bottom"></span>
  <div id="content"><!-- InstanceBeginEditable name="EditRegion1" -->
  <div id="content">
    <div class="content_box">
      <h1>Alterar senha de <span>
        <?php 
			/*Função para mostrar só o primeiro nome do usuário*/
    		//Variavel aux fazendo o explode separando pelo caracter ' '
    		$aux = explode(' ',$dados['nome_user']);
    		//Exibe o primeiro nome da string
    		echo " ".$aux[0]."\n";
			?>
      </span> </h1>
      <p>Vivamus a massa. Donec iaculis felis id neque. Praesent varius egestas velit. Donec a massa ut pede pulvinar vulputate. Nulla et augue. Sed eu nunc quis pede tristique suscipit.</p>
      <p>&nbsp;</p>
      <table width="470" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr valign="top">
          <td width="455"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><table border="0" align="right">
                    <tr>
                      <td align="center"><a href="../home.php">Voltar</a></td>
                    </tr>
                </table></td>
              </tr>
              <tr>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                </table></td>
              </tr>
              <tr>
                <td><img src="file:///D|/Meus Documentos/Igor/sites/images/img5.gif" alt="" width="100%" height="1" /></td>
              </tr>
              <tr>
                <td><table width="424" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td><form id="form1" method="post" action="<?php echo $_SERVER['../PHP_SELF']; ?>">
                          <table width="80%" border="0" cellspacing="0" cellpadding="0" align="center">
                            <tr>
                              <td class="pageName" colspan="2"><div align="center">Modificar a senha de <b><?php echo ($dados['login_user']); ?></b></div></td>
                            </tr>
                            <tr>
                              <td>&nbsp;</td>
                            </tr>
                            <tr>
                              <td>Senha atual </td>
                              <td><input type="password" name="senha_user" /></td>
                            </tr>
                            <tr>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                            </tr>
                            <tr>
                              <td>Nova senha </td>
                              <td><input type="password" name="novasenha1_user" /></td>
                            </tr>
                            <tr>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                            </tr>
                            <tr>
                              <td>Repita a Nova senha </td>
                              <td><input type="password" name="novasenha2_user" /></td>
                            </tr>
                            <tr>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                            </tr>
                            <tr>
                              <td colspan="2"><label>
                                  <div align="center">
                                    <input type="submit" name="altera" value="Alterar senha" />
                                  </div>
                                </label></td>
                            </tr>
                            <tr>
                              <td width="24%" height="25">&nbsp;</td>
                              <td height="25" width="76%"><font face="Arial" size="2">
                                <input type="hidden" name="id_user" size="35"
		value="<?php echo $dados['id_user'];?>" />
                              </font></td>
                            </tr>
                          </table>
                      </form></td>
                    </tr>
                </table></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                </table></td>
              </tr>
              <tr>
                <td align="center"><?php
if (isset($_POST['altera']))
{
	$id_user=$dados['id_user'];
	$senha = $_POST['senha_user'];
	$novasenha1_user = $_POST['novasenha1_user'];
	$novasenha2_user = $_POST['novasenha2_user'];
		
		if(($novasenha1_user)==($novasenha2_user)){
		$passwd = mysql_query("SELECT id_user, senha_user FROM tb_admin WHERE id_user='$id_user' AND senha_user='$senha'") or die("erro ao selecionar");
			if (mysql_num_rows($passwd)==1){
				$alteraSQL = mysql_query("UPDATE tb_admin SET senha_user='$novasenha1_user' WHERE id_user='$id_user'") or die("Erro no comando SQL:".mysql_error());;}
					if(($alteraSQL)==true){
						echo "<br><br><br><div align=center><font face=Arial size=4>Senha do usuário <b>$nome_user</b> alterada com Sucesso!!<br><br><a href='home.php'><< Voltar</a></font></div><br><br>";}
		
			else{echo "<div align=center><font face=Arial size=4>Senha de usuário Incorreta!!<br><br></font></div><br><br>";}
		}
		else{
		echo "<div align=center><font face=Arial size=4>As senhas digitadas são diferentes!!<br><br></font></div><br><br>";}
}
?></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
              </tr>
          </table></td>
          <td width="15">&nbsp;</td>
        </tr>
      </table>
      <p>&nbsp;</p>
    </div>
  </div>

<title>.:: Expert3d - <?php echo ($dados['login_user']); ?>::.</title>
<!-- InstanceEndEditable -->
    <div class="post_box pb_last">
      <div class="cleaner"></div>
    </div>
  </div>
  <div id="sidebar">
    <div class="sidebar_box">
      <h3>Informações</h3>
      <div class="sb_content">
        <ul class="sidebar_menu">
		  <?php if (($dados['login_user'])==(admin)){ ?> <li><a href="cadadmin.php">Cadastrar</a></li>
		  <?php } ?>
          <li><a href="altuser.php">Alterar dados </a></li>
          <li><a href="trocarphoto.php">Alterar foto</a></li>
          <li><a href="#">Free Fonts</a></li>
          <li><a href="#">Photoshop Tutorials</a></li>
          <li><a href="#">3D Animation Tutorials</a></li>
		  <li><a href="trocarsenha.php">Trocar senha</a></li>
		  <li><a href="excluir.php">Excluir conta </a></li>
        </ul>
      </div>
    </div>
    <div class="sidebar_box">
      <h3>Archives</h3>
      <div class="sb_content">
        <ul class="sidebar_menu">
          <li><a href="#">CSS Templates</a></li>
          <li><a href="#">Web Design Ideas</a></li>
          <li><a href="#">Free Wallpapers</a></li>
          <li><a href="#">Free Pixel Fonts</a></li>
          <li><a href="#">Illustrator Tutorials</a></li>
          <li><a href="#">3D Character Tutorials</a></li>
        </ul>
      </div>
    </div>
  </div>
  <div class="cleaner"></div>
</div>
<!-- end of main -->
<div id="bottom">
  <div class="bottom_box">
    <h5><span>Sed Necest</span> Suspendisse a nibh</h5>
    <p>Duis vitae velit sed dui malesuada dignissim. Donec mollis aliquet ligula. Maecenas adipiscing elementum ipsum.</p>
    <a href="#" class="continue">more info</a> </div>
  <div class="bottom_box">
    <h5><span>Lorem ipsum</span> dolor sit amet</h5>
    <p>Vestibulum eleifend, enim ut molestie pulvinar, purus est fringilla augue, ut tristique nunc neque a libero.</p>
    <a href="#" class="continue">more info</a> </div>
  <div class="bottom_box">
    <h5><span>Recent</span> Blog Post</h5>
    <ul class="bottom_box_list">
      <li><a href="#">Duis vitae velit sed lesuada dignissim.</a></li>
      <li><a href="#">Donec mollis aliquet ligula.</a></li>
      <li><a href="#">Maecenas adipiscing elementum ipsum.</a></li>
    </ul>
  </div>
</div>
<!-- end of bottom -->
<div id="footer">
  <ul class="footer_menu">
    <li class="first"><a href="#">Home</a></li>
    <li><a href="#">Web 2.0</a></li>
    <li><a href="#">Wordpress</a></li>
    <li><a href="#">Graphics</a></li>
    <li><a href="#">Inspirations</a></li>
    <li><a href="#">Freebies</a></li>
  </ul>
  Copyright &copy; 2012 <a href="home.php">Expert3d</a> | Designed by igor.giovanni@gmail.com</div>
</body>
<!-- InstanceEnd --></html>
